package com.lwm.controller;

import com.lwm.service.IAccountService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 1.ClassPathXmlApplicationContext:加载类路径下的配置文件
 * 2.FileSystemXmlApplicationContext：磁盘路径下的配置文件
 * 3.AnnotationConfigApplicationContext：读取注解创建容器
 * <p>
 * ApplicationContext：构建核心容器时，创建对象采取的策略是立即加载----饿汉----单例对象
 * BeanFactory：构建核心容器时，创建对象采用延迟加载-----懒汉----多例对象
 * </p>
 *
 * @author liweimin
 * @date 2021/6/3 1:05
 * @since
 */
public class AccountController {
    public static void main(String[] args) {
        //1.获取核心容器对象
        ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");

        //2.根据id获取Bean对象
//        IAccountService accountService = (IAccountService) ac.getBean("accountService");
        IAccountService accountService = (IAccountService) ac.getBean("accountService3");
//        IAccountService accountService = (IAccountService) ac.getBean("accountService2");

        accountService.saveAccount();

    }
}
